package com.aiobc.business.personalcenter.contoller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.aiobc.business.personalcenter.domain.DataUnopenApply;
import com.aiobc.business.personalcenter.service.DataUnopenApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aiobc.common.log.annotation.Log;
import com.aiobc.common.log.enums.BusinessType;
import com.aiobc.common.security.annotation.PreAuthorize;

import com.aiobc.common.core.web.controller.BaseController;
import com.aiobc.common.core.web.domain.AjaxResult;
import com.aiobc.common.core.utils.poi.ExcelUtil;
import com.aiobc.common.core.web.page.TableDataInfo;

/**
 * 未开放数据申请Controller
 * 
 * @author ruoyi
 * @date 2021-10-21
 */
@RestController
@RequestMapping("/apply")
public class DataUnopenApplyController extends BaseController
{
    @Autowired
    private DataUnopenApplyService dataUnopenApplyService;

    /**
     * 查询未开放数据申请列表
     */
    @PreAuthorize(hasPermi = "system:apply:list")
    @GetMapping("/list")
    public TableDataInfo list(DataUnopenApply dataUnopenApply)
    {
        startPage();
        List<DataUnopenApply> list = dataUnopenApplyService.selectDataUnopenApplyList(dataUnopenApply);
        return getDataTable(list);
    }

    /**
     * 导出未开放数据申请列表
     */
    @PreAuthorize(hasPermi = "system:apply:export")
    @Log(title = "未开放数据申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataUnopenApply dataUnopenApply) throws IOException
    {
        List<DataUnopenApply> list = dataUnopenApplyService.selectDataUnopenApplyList(dataUnopenApply);
        ExcelUtil<DataUnopenApply> util = new ExcelUtil<DataUnopenApply>(DataUnopenApply.class);
        util.exportExcel(response, list, "未开放数据申请数据");
    }

    /**
     * 获取未开放数据申请详细信息
     */
    @PreAuthorize(hasPermi = "system:apply:query")
    @GetMapping(value = "/{applyId}")
    public AjaxResult getInfo(@PathVariable("applyId") String applyId)
    {
        return AjaxResult.success(dataUnopenApplyService.selectDataUnopenApplyById(applyId));
    }

    /**
     * 新增未开放数据申请
     */
    @PreAuthorize(hasPermi = "system:apply:add")
    @Log(title = "未开放数据申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataUnopenApply dataUnopenApply)
    {
        return toAjax(dataUnopenApplyService.insertDataUnopenApply(dataUnopenApply));
    }

    /**
     * 修改未开放数据申请
     */
    @PreAuthorize(hasPermi = "system:apply:edit")
    @Log(title = "未开放数据申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataUnopenApply dataUnopenApply)
    {
        return toAjax(dataUnopenApplyService.updateDataUnopenApply(dataUnopenApply));
    }

    /**
     * 批量删除未开放数据申请
     */
    @PreAuthorize(hasPermi = "system:apply:remove")
    @Log(title = "未开放数据申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applyIds}")
    public AjaxResult remove(@PathVariable String[] applyIds)
    {
        return toAjax(dataUnopenApplyService.deleteDataUnopenApplyByIds(applyIds));
    }
}
